<template>
  <a-drawer
    title="招生目录明细"
    wrapClassName="fullscreen"
    height="100%"
    placement="bottom"
    :closable="false"
    @close="handleCancel"
    :visible="editVisible" >
    <template v-if="infoIdx==0">
       <one-info ref="one" :disabledStop="false" :info='baseInfo' @getInfoValue='getInfoValue'></one-info>
   </template>
   <template v-else-if="infoIdx==1">
       <two-info ref="two" :disabledStop="false" :info='baseInfo' ></two-info>
   </template>

    <div class="drawer-bootom-button" style="z-index:1">
        <div style="float:right">
            <a-button type="primary" @click="handlePrev" v-if="infoIdx>0">上一步</a-button>
            <a-button type="primary" @click="handleNext" v-if="infoIdx<1">下一步</a-button>
            <a-button type="primary" @click="handleCancel">关闭窗口</a-button>
        </div>
    </div>
  </a-drawer>
</template>

<script>

import OneInfo from './infoModule/one.vue'
import TwoInfo from './infoModule/two.vue'

export default {
  components: {
    OneInfo,
    TwoInfo
  },
  props: {
    editVisible: {
      default: false
    },
    info: {
      default: () => ({})
    }
  },
  data () {
    return {
      loading: false,
      postParams: {},
      imageUrl: '',
      oneData: {},
      selectMenu: {
        yx: [] // 院系
      },
      // 当前所在信息节点
      infoIdx: 0,
      baseInfo:{}
    }
  },
  created () {
    // 设置信息一假数据
    this.oneData = {
      zsrs: '200'
    }
    // 设置信息二假数据
    this.twoData = {
      data: [],
      yx: '100',
      zy: '200'
    }
  },
  watch:{
    info(){
      console.log(this.info)
      this.baseInfo = this.info
      this.baseInfo.zsSsszszyml = {"id":this.baseInfo.id}
    }
  },
  methods: {
    // 关闭
    handleCancel () {
      this.infoIdx = 0
      this.$emit('close')
    },
    getInfoValue(newData){
       // 验证通过处理数据
      if (newData) {
         if(newData.id){
            this.$api.recruitstat.setUpBySpecialtyId(newData.id).then( res => {
               this.baseInfo = res.data
               this.baseInfo.zsSsszszyml = {"id":newData.id}

            })
          }else{
            this.baseInfo = newData
            this.baseInfo.zsSsszszyml = {"id":newData.zsSsszszyml.id}
          }
          this.infoIdx++

        // 验证不通过不跳转下一页
      } else {
        console.log('哈哈')
        // this.infoIdx++
      }
    },

    // 下一页
    handleNext () {
      switch (this.infoIdx) {
        case 0:
          this.$refs.one.GetInfo()
          break
        case 1:
          this.$refs.two.GetInfo()
          break
      }

    },
    // 下一页
    // handleNext () {
    //   let d
    //   switch (this.infoIdx) {
    //     case 0:
    //       d = this.$refs.one.GetInfo()
    //       break
    //     case 1:
    //       d = this.$refs.two.GetInfo()
    //       break
    //   }
    //   // 验证通过处理数据
    //   if (d) {
    //     this.infoIdx++
    //     // 验证不通过不跳转下一页
    //   } else {
    //     console.log('哈哈')
    //     this.infoIdx++
    //   }
    // },
    // 上一页
    handlePrev () {

      this.infoIdx--
    },
    // 保存修改
    handleSave () {

    }
  }
}
</script>

<style lang="less">
.fullscreen{
    .ant-drawer-wrapper-body{
        height: 100%;
        overflow: auto;
    }
}
</style>
